-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSV panel actions for SavedSearch embedabbles #33709
CSV panel actions for SavedSearch embedabbles #33709
Conversation
|
||
public isVisible = (panelActionAPI: PanelActionAPI): boolean => { | ||
const { embeddable } = panelActionAPI; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to go with duck-type-typing here since it was proving to be impossible to import the SavedSearchEmbedable component :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so the actual class we want is from src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts
, which is an extension of the Embeddable class. That's why we have to check for the savedSearch
property to make sure it's valid?
In that case, I think this could use a comment to marker where we might be able to improve things down the road.
💚 Build Succeeded |
@@ -28,7 +28,9 @@ class PanelActionsStore { | |||
*/ | |||
public initializeFromRegistry(panelActionsRegistry: ContextMenuAction[]) { | |||
panelActionsRegistry.forEach(panelAction => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some reason panel actions are duped everytime you re-enter a page when client-side routing occurs. This fixes that.
|
||
await kfetch({ method: 'POST', pathname: `${API_BASE_URL}${id}`, body }, { parseJson: false }) | ||
.then(r => r.text()) | ||
.then(csv => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a nasty client-side mechanism to do CSV downloads browser-side. Might want to consolidate this into some sort of util elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like typical JS to me 😁
import { kfetch } from 'ui/kfetch'; | ||
import { toastNotifications } from 'ui/notify'; | ||
|
||
const API_BASE_URL = '/api/reporting/v1/generate/immediate/csv/saved-object/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worthwhile to import the base URL path (API_BASE_URL_V1
) from '../../common/constants'
const state = await this.generateJobParams({ searchEmbeddable }); | ||
|
||
const id = `search:${embeddable.savedSearch.id}`; | ||
const filename = embeddable.savedSearch.title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe next, we should work on exposing the SearchEmbeddable interface here, because .savedSearch
and .$rootScope
are typed as private in src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the other headaches with the SearchEmbeddable
interface (😁) it seems too limited for the definition to be in /discover
. The Discover app is used for creating a saved search... but having the defined structure of a saved search is important all over the Kibana codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I'm going to add another issue where we do some cleanup/migration of this component so we can better use it in our x-pack code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of comments, which are really more for discussion. The only things I'm really interested to see changed are the thing about using the constants file, and adding that minor comment.
}; | ||
|
||
private onGenerationFail(error: Error) { | ||
toastNotifications.addDanger({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💚
} | ||
|
||
const searchEmbeddable = embeddable; | ||
const state = await this.generateJobParams({ searchEmbeddable }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be wrapped in _.pick
to whitelist fields that we care about. For example, we don't care about highlight
, size
, and script_fields
(since they can't create script fields on-the-fly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is just a comment of something we can figure out later, because I'm not sure what we need at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing (that doesn't need to be figured out right now) - this object doesn't seem to contain the columns.
- Create a saved search
- Add it to a dashboard
- Change the columns in the panel of the dashboard
- We need to figure out how to get the columns to show, it's not in this
state
(but it could be)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
💔 Build Failed |
💔 Build Failed |
f43ad9f
to
34677f2
Compare
There's a valid test failure of some of our code being wrong after the master merge:
|
💔 Build Failed |
I've thrown down some TODO's as well as hidden the export in edit mode. I think that resolves most of the comments here @tsullivan if you want to give it a final glance. After that we can begin the PR from our feature branch back into master. I don't mind taking ownership of that. |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fb3776c
into
elastic:feature/reporting/csv-export-panel-action
Congrats on the merge! great job :) |
Retry of #32522 since this PR wasn't showing the appropriate deltas.